// 工作流节点类型
export interface WorkflowNode {
    id: string
    type: string
    position: {
        x: number
        y: number
    }
    data?: Record<string, any>
}

// 工作流连接类型
export interface WorkflowEdge {
    id: string
    source: string
    target: string
    type?: string
    data?: Record<string, any>
}

// 工作流配置类型
export interface WorkflowConfig {
    nodes: WorkflowNode[]
    edges: WorkflowEdge[]
}

// 工作流参数选项
export interface ParamOption {
    label: string
    value: string | number
}

// 工作流参数
export interface WorkflowParam {
    id: string
    type: 'text' | 'number' | 'select' | 'image' | 'switch' | 'slider'
    label: string
    description?: string
    placeholder?: string
    default?: any
    required?: boolean
    visible?: boolean
    min?: number
    max?: number
    step?: number
    options?: ParamOption[]
}

// 参数组
export interface ParamGroup {
    id: string
    title: string
    params: string[]
    visible?: boolean
}

// 工作流模板布局
export interface TemplateLayout {
    groups: ParamGroup[]
}

// 工作流模板
export interface WorkflowTemplate {
    version: string
    workflow: WorkflowConfig
    params: WorkflowParam[]
    layout: TemplateLayout
}

// 工作流执行参数
export interface ExecutionParams {
    [key: string]: any
}

// 工作流执行结果
export interface ExecutionResult {
    images?: string[]
    data?: any
    error?: string
}

// 工作流执行状态
export type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed'

// 工作流执行记录
export interface ExecutionRecord {
    id: string
    status: ExecutionStatus
    result?: string
    error?: string
    params: string
    startTime: Date
    endTime?: Date
    workflowId: string
    workflow?: WorkflowData
    userId: string
    user?: {
        id: string
        username: string
        email: string
    }
    createdAt: Date
    updatedAt: Date
}

// 工作流服务器配置
export interface ServerConfig {
    id: string
    name: string
    url: string
    type: string
    status: 'online' | 'offline' | 'busy'
    capabilities: string[]
}

// 工作流权限
export interface WorkflowPermission {
    execute: boolean
    edit: boolean
    delete: boolean
    share: boolean
}

// 工作流统计信息
export interface WorkflowStats {
    totalExecutions: number
    successfulExecutions: number
    failedExecutions: number
    averageExecutionTime: number
    lastExecutionTime?: Date
}

// 工作流定义
export interface Workflow {
    id: string
    name: string
    title: string
    description?: string
    type: string
    workflow: string
    template: string
    cover: string
    detailImage?: string
    samples: string[]
    isPublic: boolean
    serverIds: string[]
    excludeServerIds: string[]
    powerConsumption?: number
    sort?: number
    tags: string[]
    userId: string
    createdAt: Date
    updatedAt: Date
} 